void main() {
  Person person = Person();
  person.name = '张三';
  person.age = 39;
  person.sayHello();

  print('--------------------------');

  Teacher teacher = Teacher();
  teacher.name = '李四';
  teacher.age = 28;
  teacher.sayHello();
  teacher.saySubject();

  print('--------------------------');

  Student student = Student();
  student.name = '王五';
  student.age = 18;
  student.sayHello();
  student.sayMajor();
}

//定义一个父类
class Person {
  String name = '人类';
  int age = 18;

  //定义方法
  void sayHello() {
    print('你好，我是$name，今年$age岁');
  }
}

//定义一个老师类
class Teacher extends Person {
  String subject = '鸿蒙';

  void saySubject() {
    print('我是老师,我教的课程是$subject');
  }

  //重写父类的方法
  @override
  void sayHello() {
    super.sayHello();
    print('你好，我是$name，今年$age岁,我教的课程是$subject');
  }
}

//定义一个学生类
class Student extends Person {
  String major = '鸿蒙';

  void sayMajor() {
    print('我是学生,我修的课程是$major');
  }
}
